package cn.bugstack.gateway.session;


import cn.bugstack.gateway.session.defaults.GenericReferenceSessionFactory;
import io.netty.channel.Channel;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

// 会话工厂builder,最后返回的是 Future<Channel>
public class GenericReferenceSessionFactoryBuilder {
    public Future<Channel> build(Configuration configuration) {
        IGenericReferenceSessionFactory sessionFactory = new GenericReferenceSessionFactory(configuration);
        try {
            // 返回 Future<Channel>
            return sessionFactory.openSession();

        } catch (ExecutionException | InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
